package com.example.myanimtweened;

import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {
    /**补间动画*/

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        ImageView imageView = findViewById(R.id.iv);

        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                // 通过加载xml动画设置文件来创建一个Animation 对象
                //透明度 alpha
//                Animation animation = AnimationUtils.loadAnimation(MainActivity.this,
//                        R.anim.alpha);

                // 旋转 rotate
//                Animation animation = AnimationUtils.loadAnimation(MainActivity.this,
//                        R.anim.rotate);
//                imageView.startAnimation(animation);

                // 缩放 scale，从原图缩小到大小的一半
//                Animation animation = AnimationUtils.loadAnimation(MainActivity.this,
//                        R.anim.scale);
//                imageView.startAnimation(animation);

                // 平移 translate
                Animation animation = AnimationUtils.loadAnimation(MainActivity.this,
                        R.anim.translate);
                imageView.startAnimation(animation);

            }
        });
    }
}